package com.magenta.maxoptra.gis;

import static com.magenta.maxoptra.gis.GISFieldType.BOOLEAN;
import static com.magenta.maxoptra.gis.GISFieldType.TEXT;

/**
 * Yandex attributes
 *
 * @author Zaur Muhametgaleev
 * @version 12/16/11 12:47 PM
 * @see "jira task MRS-4161: Add support of Yandex geo provider"
 * @since Maxoptra 3 (GT)
 */
public enum YandexAttribute implements GISAccountProperty {
    UseProvider(GisParameter.use_map_provider, MapProviderType.yandex, GISFieldType.BOOLEAN, "false", true, true, 0L),
    YandexRouterUrl(GisParameter.routing_url, MapProviderType.yandex, TEXT, "http://maps.yandex.ru/actions/get-route/?rt={0},{1}~{2},{3}", true, true, 1L),
    YandexGeocoderUrl(GisParameter.geocoding_url, MapProviderType.yandex, TEXT,
            "http://geocode-maps.yandex.ru/1.x/?geocode={0}&format=json&key={1}", true, true, 2L),
    YandexUseCustomGeoAddressForm(GisParameter.use_custom_geo_address_form, MapProviderType.yandex, BOOLEAN, "false", false, true, 3L),
    //    YandexUseShortestRoute(use_shortest_route, yandex, BOOLEAN, "true", false, 4L),
    YandexEnableLog(GisParameter.enableLogging, MapProviderType.yandex, GISFieldType.BOOLEAN, "false", false, true, 5L),
    YandexEnableCache(GisParameter.enableCache, MapProviderType.yandex, GISFieldType.BOOLEAN, "true", true, true, 6L),
    YandexMapKey(GisParameter.map_key, MapProviderType.yandex, GISFieldType.TEXT, "", true, true, 7L),
    YandexLocale(GisParameter.locale, MapProviderType.yandex, GISFieldType.TEXT, "ru_RU", true, true, 8L),
    YandexMapUseMultiplePointsRouting(GisParameter.useMultiplePointsRouting, MapProviderType.yandex, GISFieldType.BOOLEAN, "false", false, true, 9L);

    private String name;
    private String label;
    private String tab = "GIS";
    private Long order;
    private GISFieldType type;
    private String defaultValue;
    private boolean required;
    private String groupName;
    private boolean important = true;

    public boolean isImportant() {
        return important;
    }

    private YandexAttribute(String name, String label, GISFieldType type, String defaultValue,
                            boolean required, boolean important,String groupName, Long order) {
        this.name = name;
        this.label = label;
        this.type = type;
        this.defaultValue = defaultValue;
        this.groupName = groupName;
        this.required = required;
        this.order = order;
        this.important = important;
    }

    private YandexAttribute(GisParameter parameter, MapProviderType providerType, GISFieldType type,
                            String defaultValue, boolean required, boolean important, Long order) {
        this(parameter.withProvider(providerType.name()),
                parameter.getLabel(),
                type,
                defaultValue,
                required,
                important,
                providerType.getLabel(),
                order);
    }

    public String getName() {
        return name;
    }

    public GISFieldType getType() {
        return type;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public Boolean getMandatory() {
        return required;
    }

    public String getGroup() {
        return groupName;
    }

    public String getLabel() {
        return label;
    }

    public Long getOrder() {
        return order;
    }

    public String getTab() {
        return tab;
    }

    public boolean isReadOnly() {
        return false;
    }

}
